package com.sky.controller.admin;

import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.utils.result.PageResult;
import com.sky.utils.result.Result;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
* 菜品管理
* */
@Slf4j
@RestController
@Api(tags ="菜品相关接口" )
@RequestMapping("/admin/dish")
public class DishController {

    @Autowired
    private DishService dishService;
    /*
    * 新增菜品
    * */
    @ApiOperation("新增菜品")
    @PostMapping
    public Result save(@RequestBody DishDTO dishDTO)
    {
        log.info("新增菜品: {}",dishDTO);
        dishService.saveWithFlavor(dishDTO);
        return Result.success();
    }

    /*
    *
    * 菜品分页查询
    * */
    @ApiOperation("菜品分页查询")
    @GetMapping("page")
    public Result<PageResult> PageQuery(DishPageQueryDTO dishPageQueryDTO)
    {

        log.info("菜品分页查询");
        PageResult pageResult=  dishService.PageQuery(dishPageQueryDTO);
        return  Result.success(pageResult);
    }



    /*
    * 删除菜品(批量)
    * */
    @DeleteMapping
    @ApiOperation("删除菜品")
    public Result delete(@RequestParam List<Long> ids)
    {
        log.info("删除菜品 ：{}",ids);
        dishService.deleteBatch(ids);
        return  Result.success();
    }




    /*
    * 根据id查询菜品
    * */

    /*
    * 修改菜品
    * */


}
